package com.per.yyyFrame.enums;

/**
 * @Author : Meryl
 * @Description:
 * @Date: Created in 2018/12/18
 * @Modify by :
 */
public enum RespCode {

    SUCCESS(0, "操作成功"),
    ERROR(-999, "操作失败"),
    PARAM_ERROR(1001, "参数错误"),
    USER_NOT_EXIST(1002, "用户不存在"),
    INVALID_PERMISSION(1005, "不具有权限"),
    INVALID_SIGN(1006, "参数签名不正确"),
    DATA_EXCEPTION(2001, "数据异常"),
    BIZ_FAILED(2002, "业务处理失败");

    private final Integer code;
    private final String msg;

    RespCode(Integer code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public static RespCode getEnumByCode(Integer code) {
        if (null == code) {
            return null;
        }
        for (RespCode temp : RespCode.values()) {
            if (temp.getCode().equals(code)) {
                return temp;
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public String getMsg() {
        return msg;
    }
}
